package com.example.research.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 横向课题实体类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class HorizontalProject {

    private Long id;

    @NotBlank(message = "项目名称不能为空")
    @Size(max = 200, message = "项目名称长度不能超过200个字符")
    private String projectName;

    @Size(max = 100, message = "合同号长度不能超过100个字符")
    private String contractNumber;

    @DecimalMin(value = "0.0", message = "合同总金额不能为负数")
    private BigDecimal contractAmount;

    @Size(max = 200, message = "甲方单位名称长度不能超过200个字符")
    private String partyName;

    @Size(max = 100, message = "项目负责人长度不能超过100个字符")
    private String projectLeader;

    @Size(max = 100, message = "执行负责人长度不能超过100个字符")
    private String executionLeader;

    private LocalDate startDate;

    private LocalDate endDate;

    private String fundingRecords;

    private String participants;

    @Size(max = 100, message = "财务账号长度不能超过100个字符")
    private String financialAccount;

    @Size(max = 200, message = "到款凭证长度不能超过200个字符")
    private String paymentVoucher;

    private LocalDate completionDate;

    @Size(max = 200, message = "结题证明长度不能超过200个字符")
    private String completionCertificate;

    @Size(max = 200, message = "结题报告长度不能超过200个字符")
    private String completionReport;

    private Long userId;

    private Integer auditStatus; // 0:待审核 1:审核通过 2:审核拒绝

    private String auditComment;

    private LocalDateTime createdTime;

    private LocalDateTime updatedTime;

    // 填报日期
    private LocalDateTime reportDate;

    // 关联的用户信息
    private User user;

    /**
     * 获取审核状态描述
     */
    public String getAuditStatusDesc() {
        if (auditStatus == null) {
            return "未知";
        }
        switch (auditStatus) {
            case 0: return "待审核";
            case 1: return "审核通过";
            case 2: return "审核拒绝";
            default: return "未知";
        }
    }

    /**
     * 检查是否可以修改
     */
    public boolean canModify() {
        return auditStatus == null || auditStatus == 0 || auditStatus == 2;
    }
}
